package Java8实战._1_Lambda._9_Lambda应用;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

public class _9_1_2_Lambda应用_Consumer {

    public static void main(String[] args) {

        List<String> list = Arrays.asList(
                "qwe",
                "123456789",
                "jiangboyang",
                "dajiang"
        );

        print(list,(String str) -> System.out.print(str + "\t"));

        System.out.println("\n=========================\n");

        print(list,(String str) -> System.out.println(str + "，字符长度为：" + str.length()));
    }

    public static <T> void print(List<T> list, Consumer<T> consumer){

        for (T t : list){
            consumer.accept(t);
        }
    }
}
